
/**
 * AppleIIGo
 * Interrupt class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "Interrupt.h"

Interrupt::Interrupt(Motherboard * motherboard, char * deviceName) :
	Device(motherboard, deviceName) {
	isEnabledValue = false;
	isAssertedValue = false;
}

void Interrupt::onDevicesConnected() {
	cpu = motherboard->getCpu();
}

void Interrupt::enable(bool value) {
	isEnabledValue = value;
	if (!value)
		clear();
}

void Interrupt::assert() {
	if (isEnabledValue && !isAssertedValue) {
		isAssertedValue = true;
		cpu->assertIrq();
	}
}

void Interrupt::clear() {
	if (isAssertedValue) {
		isAssertedValue = false;
		cpu->clearIrq();
	}
}

bool Interrupt::isEnabled() {
	return isEnabledValue;
}

bool Interrupt::isAsserted() {
	return isAssertedValue;
}
